/*
 * @Author       : Hejh(3010733382@qq.com)
 * @Version      : V1.0
 * @Date         : 2024-02-01 11:59:32
 * @Description  : 封装全局loading，用于命令式loading
 */

import { createApp } from 'vue'
import myLoad from '@/components/Loading/index.vue'

const config = reactive({
  isLoading: true
})

const $loading = createApp(myLoad, {
  config
}).mount(document.createElement('div'))

const load = {
  show() {
    // 控制显示loading的方法
    config.isLoading = true
    document.body.appendChild($loading.$el)
  },
  hide() {
    // 控制loading隐藏的方法
    config.isLoading = false
    $loading.$el.remove()
  }
}
export { load }
